<script setup lang="ts">
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
import { reactive, ref } from 'vue'
// import { ucMyOrgListApi } from '@/api/cy/xPanrule'
import { useTable } from '@/hooks/web/useTableTest'
import { zcPastureListAdminApi } from '@/api/fa/pasture'

const crudSchemas = reactive<CrudSchema[]>([
  {
    field: 'org_name',
    label: '牧场名称',
    search: {
      show: true
    }
  }
  // {
  //   field: 'org_id',
  //   label: '牧场ID',
  //   search: {
  //     show: true
  //   }
  // },
  // {
  //   field: 'code',
  //   label: '牧场编号',
  //   search: {
  //     show: true
  //   }
  // }
])

const { allSchemas } = useCrudSchemas(crudSchemas)

const { register, tableObject, methods } = useTable<
  {
    total: number
    list: any[]
  },
  any
>({
  getListApi: zcPastureListAdminApi,
  response: {
    data: 'data',
    count: 'count'
  }
})

const { getList, setSearchParams } = methods

getList()

// const emit = defineEmits(['shi'])
let aaa = ref()
const save = async (row) => {
  aaa.value = row
}
defineExpose({
  aaa
})
</script>

<template>
  <ContentWrap>
    <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />

    <Table
      v-model:pageSize="tableObject.pageSize"
      v-model:currentPage="tableObject.currentPage"
      :columns="allSchemas.tableColumns"
      :data="tableObject.tableList"
      :loading="tableObject.loading"
      :border="false"
      :pagination="{
        total: tableObject.count
      }"
      @register="register"
      :selection="false"
      highlight-current-row
      @row-click="save"
    />
  </ContentWrap>
</template>
<style scoped></style>
